package com.da.javatest.leetCode2;

public class Code162 {
    public int findPeakElement(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            int preNum = i == 0 ? Integer.MIN_VALUE : nums[i - 1];
            int nextNum = i == nums.length - 1 ? Integer.MIN_VALUE : nums[i + 1];
            if (nums[i] > preNum && nums[i] > nextNum) {
                return i;
            }
        }
        return 0;
    }
}
